function getUrlParam(): any {
  var url = location.href;
  if (url.indexOf("?") !== -1) {
    var arr = url.split("?");
    arr.shift();
    var str = arr.join("?");
    arr = str.split("&");
    var obj = {};
    for (var i = 0, ii; (ii = arr[i++]); ) {
      var mid = ii.split("=");
      var key = mid.shift();
      obj[key] = mid.join("=");
    }
    return obj;
  }
  return null;
}
//https://aiot.shenling.com/static/protocol/index.html?type=user&terminal=pc

const TYPES = ["user", "privacy"];
const TERMIALS = ["pc", "mp", "android", "ios"];
let { type, terminal } = getUrlParam() || {};
if (!type || !TYPES.includes(type)) {
  type = "user";
}
if (!terminal || !TERMIALS.includes(terminal)) {
  terminal = "pc";
}

const modules = import.meta.glob("./**/*.html", { as: "raw" });
async function init() {
  const module = await modules[`./${terminal}/${type}.html`]();
  document.body.innerHTML = module;
}
init();
